using UnityEngine;
using System.Collections;

public class DoorControl : StateBehaviour<DoorControl>, ISwitch
{
    #region Attributes

    public bool isBeginsOpen = false;

    #endregion

    #region Unity Methods

    void Start()
    {
        if (this.isBeginsOpen)
            this.State = DoorOpenState.Instance;
        else
            this.State = DoorCloseState.Instance;
    }

    #endregion

    #region Methods
    
    public void PlayAnimation(string name)
    {
        this.animation.CrossFade(name);
    }

    #endregion

    #region StateBehaviour

    public override void OnUpdate()
    {
        
    }

    public override DoorControl GetBehaviuor()
    {
        return this;
    }

    #endregion

    #region ISwitch

    public void Open()
    {
        this.State.OnAction(ActionConstants.OPEN, this);
    }

    public void Close()
    {
        this.State.OnAction(ActionConstants.CLOSE, this);
    }

    public void Switch()
    {
        this.State.OnAction(ActionConstants.SWITCH, this);
    }

    #endregion
}
